package cn.edu.nju.software.cdiy.algorithm.performance;

import cn.edu.nju.software.cdiy.bean.Radiator;
import cn.edu.nju.software.cdiy.util.Constant;

public class RadiatorEvaluator implements Evaluator<Radiator>{

	@Override
	public double getPerformance(Radiator t) {
		double score = 0;
		
		//最高转速
		int highestSpeed = t.getHighestSpeed();
		double highestSpeedScore = getHighestSpeedBase(highestSpeed)*Constant.RAD_STD_HIGHESTSPEED;
		
		//噪音
		double noise = t.getNoise();
		double noiseScore = getNoiseBase(noise)*Constant.RAD_STD_NOISE;
		
		
		//散热方式
		int type = t.getType().getKey();
		double typeScore = getTypeBase(type)*Constant.RAD_STD_TYPE;
		

		score = highestSpeedScore+noiseScore+typeScore;
		return score;
	}

	private double getTypeBase(int type) {
		/*
		 * 散热方式基础分
		 * 761				90
		 * 763				80
		 * 762 764			70	
		 * 
		 * */
		if(type==761)
			return 90;
		else if(type==763)
			return 80;
		else return 70;
	}

	private double getNoiseBase(double noise) {
		/*
		 * 噪音基础分
		 * -10			90
		 * 10-15		85
		 * 15-20		80
		 * 20-25		75
		 * 25-30		70
		 * 30-35		65
		 * 35-40		60
		 * 40-			50
		 * */
		if(noise<10)
			return 90;
		else if(noise>=10 && noise<15)
			return 85;
		else if(noise>=15 && noise<20)
			return 80;
		else if(noise>=20 && noise<25)
			return 75;
		else if(noise>=25 && noise<30)
			return 70;
		else if(noise>=30 && noise<35)
			return 65;
		else if(noise>=35 && noise<40)
			return 60;
		else if(noise>40)
			return 50;
		else return 50;
	}

	private double getHighestSpeedBase(int highestSpeed) {
		/*
		 * 最高转速基础分
		 * 500-1000			50
		 * 1000-1500		60
		 * 1500-2000		70
		 * 2000-2500		80
		 * 2500-3000		85
		 * 3000-			90
		 * */
		if(highestSpeed<=1000)
			return 50;
		else if(highestSpeed>1000 && highestSpeed<=1500)
			return 60;
		else if(highestSpeed>1500 && highestSpeed<=2000)
			return 70;
		else if(highestSpeed>2000 && highestSpeed<=2500)
			return 80;
		else if(highestSpeed>2500 && highestSpeed<=3000)
			return 85;
		else if(highestSpeed>3000)
			return 90;
		else return 95;
	}

}
